import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_auth/pages/login/loginWidget.dart';
import 'package:flutter_styled_toast/flutter_styled_toast.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_auth/pages/index/indexWidget.dart';
import 'package:flutter_auth/constants.dart';
import './common/router.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // 定义全局的路由导航实例，方便所有非widget进行路由跳转功能
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return StyledToast(
      locale: const Locale('zh', 'CH'),
      textStyle: TextStyle(fontSize: 16.0, color: Colors.white),
      backgroundColor: Color(0x99000000),
      borderRadius: BorderRadius.circular(5.0),
      textPadding: EdgeInsets.symmetric(horizontal: 17.0, vertical: 10.0),
      toastAnimation: StyledToastAnimation.size,
      reverseAnimation: StyledToastAnimation.size,
      startOffset: Offset(0.0, -1.0),
      reverseEndOffset: Offset(0.0, -1.0),
      duration: Duration(seconds: 4),
      animDuration: Duration(seconds: 1),
      alignment: Alignment.center,
      toastPositions: StyledToastPosition.center,
      curve: Curves.fastOutSlowIn,
      reverseCurve: Curves.fastOutSlowIn,
      dismissOtherOnShow: true,
      movingOnWindowChange: true,
      child: MaterialApp(
        localizationsDelegates: [
          GlobalMaterialLocalizations.delegate,
          GlobalWidgetsLocalizations.delegate,
        ],
        supportedLocales: [
          const Locale('zh', 'CH'),
        ],
        navigatorKey: Router.navigatorKey, // 定义导航key
        debugShowCheckedModeBanner: false,
        routes: {
          "/indexWidget": (context) => new IndexWidget(),
        },
        theme: ThemeData(
          primaryColor: kPrimaryColor,
          scaffoldBackgroundColor: Colors.white,
        ),
        home: LoginWidget(),
      ),
    );
  }
}
